package com.googlecode.ozonbooksfinder.cairngormfinder.model
{
	import com.adobe.cairngorm.model.ModelLocator;
	import com.googlecode.ozonbooksfinder.domain.Book;
	import com.googlecode.ozonbooksfinder.domain.SearchContext;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class CairngormFinderModelLocator implements ModelLocator
	{
		private static var modelLocator : CairngormFinderModelLocator;
		
		public static function getInstance() : CairngormFinderModelLocator 
		{
			if ( modelLocator == null )
			{
				modelLocator = new CairngormFinderModelLocator();
			}
			
			return modelLocator;
		}
		
		public function CairngormFinderModelLocator() 
		{	
			if ( modelLocator != null )
			{
				throw new Error( "Only one CairngormFinderModelLocator instance should be instantiated" );	
			}
		}
		
		public static const VIEW_MAIN_BOOK_LIST_SEARCH:String = "viewMainBookListSearch";
		
		public static const VIEW_MAIN_BOOK_LIST_FAVORITES:String = "viewMainBookListFavorites";
		
		public static const VIEW_MAIN_BOOK_LIST:String = "viewMainBookList";
		
		public static const VIEW_STATE_MAIN_SEARCH:int = 0;
		
		public static const VIEW_STATE_MAIN_BOOK_LIST:int = 1;
		
		public var currentBook:Book;

		public var currentSearchString:String;

		public var currentSearchContext:String  = SearchContext.DIV_BOOK;
		
		public var booksDataProvider:ArrayCollection;
		 
		public var favoritesDataProvider:ArrayCollection; 
		
		public var mainViewState:int = VIEW_STATE_MAIN_SEARCH;
		
		public var searchMode:Boolean = true;

	}
}